home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6883 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: tor.teorfys.lu.se!coa
  2. From: coa@tor.teorfys.lu.se (Carl-Olof Almbadh)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: void main() and other atrocities!
  5. Date: 15 Feb 1996 23:20:09 GMT
  6. Organization: Department of Theoretical Physics, Lund University
  7. Message-ID: <4g0f39$q41@merkurius.lu.se>
  8. References: <4eduaj$1aq@grouper.Exis.Net> <4em17r$shq@jaxnet.jaxnet.com> <6P/Hx0zpkXSB088yn@merlin.magic.mb.ca>
  9. NNTP-Posting-Host: tor.teorfys.lu.se
  10.  
  11. In article <6P/Hx0zpkXSB088yn@merlin.magic.mb.ca>, wrightd@merlin.magic.mb.ca (David C. Wright) writes:
  12. |> 
  13. |> My understanding is that declarations such as
  14. |> 
  15. |> char *(buffer1[2]);
  16. |> 
  17. |> and
  18. |> 
  19. |> char **buffer2;
  20. |> 
  21. > differs in only one respect.  The constant 'buffer1' is an RVALUE. The
  22. > variable 'buffer2' is an LVALUE.
  23.  
  24. In fact they are completely different. Both buffer1[i][j] and buffer2[i][j]
  25. are l-values but the compiler computes their addresses in different ways.
  26. The address of buffer1[i][j] is valuse stored is:
  27.  buffer1 + (i+2 + j) * sizeof(char)
  28. There is only one referencing.
  29.  
  30. In order to fetch buffer2[i][j] we must first fetch the char pointer
  31. buffer2[i] from memory. This new value is then incremented by j*sizeof(char)
  32. and one byte at the last address is fetched from memory.Thus there are
  33. two pointers involved, both of which must be referenced to fetch a char.
  34.  
  35. Carl-OLof Almbladh
  36. Lund Univ.
  37. coa@teorfys.lu.se
  38.  
  39.